|
|
|
|
|
|
|
Figure 13.3
Rotating a point around the Z axis until
it lies in the X-Z plane. |
|
|
|
|
|
|
|
|
You can write a Visual Basic subroutine to initialize a transformation matrix that rotates around the Z axis until a point lies in the X-Z plane like this: |
|
|
|
 |
|
|
|
|
' Create a matrix that rotates around the Y axis
' so the point (x, y, z) lies in the X-Z plane. Public Sub m3YRotateIntoXZ(Result() As Single, _
ByVal x As Single, ByVal y As Single, ByVal z As Single)
Dim d As Single
m2Identity Result
d = Sqr(x * x + y * y)
Result(1, 1) = x / d
Result(1, 2) = -y / d
Result(2, 1) = -Result(1, 2)
Result(2, 2) = Result(1, 1)
End Sub |
|
|
|
|
|
|
|
|
Notice that you could also have rotated around the X axis to move the point into the X-Z plane, as shown in Figure 13.4. While both of these rotations move the point into the X-Z plane, they place the point in different positions. |
|
|
|
|
|
|
|
|
Figure 13.4
Rotating a point around the X axis until
it lies in the X-Z plane. |
|
|
|
|
|